package com.glory.njcleanrpt;

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.List;

/**
 * @ProjectName: shcleanrpt
 * @ClassName: DataUtil
 * @Author: Ivan
 * @Date: 2019-06-26 17:04
 * @Version 1.0
 */
public class DataUtil {

	/**
	 * 保留两位小数,进行四舍五入
	 * @Author Ivan
	 * @Date 2019/6/26
	 * @Params
	 * @Return java.lang.Double
	 */
	public static Double saveOneBitTwoRound(Double d) {
		BigDecimal bd = new BigDecimal(d);
		Double res = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
		return res;
	}

	/**
	 * 去重
	 * @Author Ivan
	 * @Date 2019/7/11
	 * @Params
	 * @Return java.util.List
	 */
	public static List removeDuplicate(List list) {
		HashSet h = new HashSet(list);
		list.clear();
		list.addAll(h);
		return list;
	}

	public static void main(String args[]){
		System.out.println(saveOneBitTwoRound(2.123456));;
	}
}